<?php
function numberFormat($number,$decimals = 0 , $dec_point = '.' , $thousands_sep = ',' ) { 
	if(phpversion() >=5.4){
		number_format($number,$decimals,$dec_point,$thousands_sep);
	}
	else {
	
		return str_replace(",",".",number_format($number, $decimals));
		
	}
    if ($decimals == 1) { 
        $number = sprintf('%.2f', $number); 
    }
    while (true) { 
        $replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1.$2', $number); 
        if ($replaced != $number) { 
            $number = $replaced; 
        } else { 
            break; 
        } 
    } 
    return $number; 
}

?>